<%@ page contentType="text/html;charset=utf-8" language="java"
	pageEncoding="UTF-8" import="java.util.Date"%>
<%@include file="../common/mastertop.jsp"%>
<div id="seach" class="mainInner"> 
<p class="page-title">
	<i class="locale-icon"></i> <span>当前位置 : </span> <span
		class="cur-page-title">门店管理</span> <span>· 店员管理</span>
</p>
 <form class="form-inline clearfix"   id="seachform" action="${pageContext.request.contextPath}/admin/shopuser/index"	method="post">
 	<div class="filter-warp rect-fff clearfix">
		<div class="form-group col-xs-6 col-lg-4">
			<span class="form-label">门店名</span> <input type="text"
				class="form-control form-control-260" name="shopName" value="${model.shopName}"
				>
		</div>

		<div class="form-group col-xs-6 col-lg-4">
			<span class="form-label">姓名</span> <input type="text"
				class="form-control form-control-260" 
				name="realName" value="${model.realName}" >
		</div>
			
		<div class="col-xs-12  text-center">
			<button type="button" class="btn runmi-primary buttonrole"
				onclick="edit('')" name="btnadd">新&nbsp;增</button>
			<button type="button" class="btn runmi-primary search-btn"
				onclick="seach()">查询</button>
		</div>
	</div>
	
	<div class="rect-fff table-warp">
		<div class="table-scroll">


			<table>
				<tr>
					<th>操作</th>
					<th>用户名</th>
					<th>店员姓名</th>
					<th>手机</th>
					<th>所属门店编码</th>
					<th>所属门店名</th>					
					<th>地址</th>
					<th>状态</th>
					<th>创建时间</th>
					
				</tr>
				<c:forEach items="${model.items}" var="item" varStatus="itemStatus">
					<tr  id="row_${item.id}">
						<td >							
							<span class="rm-table-btn buttonrole"  onclick="edit('${item.id}');"  name="btnedit" >修改</span>

								
							<c:choose>

								<c:when test="${item.status == '0' }">
									<span class="rm-table-btn buttonrole"  onclick="confirm('${item.id}',1);"  name="btnstatus"   >停用</span>
								</c:when>
								<c:when test="${item.status == '1' }">
									<span class="rm-table-btn buttonrole"  onclick="confirm('${item.id}',0);"   name="btnstatus"  >启用</span>
								</c:when>
								<c:otherwise>

								</c:otherwise>
							</c:choose>


						</td>
						<td>${item.usr_name}</td>
						<td>${item.real_name}</td>
						<td>${item.mobile}</td>
						<td>${item.shop_code}</td>
						<td>${item.shop_name}</td>
						<td>${item.prov_name}-${item.city_name}-${item.area_name}-${item.address}</td>
						<td  align="center" class="cdr fw7">
						<c:choose>
							<c:when test="${item.status == '0'}">
								停用 
							</c:when>
							<c:when test="${item.status == '1'}">
								启用
							</c:when>
							<c:otherwise>
								
							</c:otherwise>
						</c:choose>
						</td>
						<td><fmt:formatDate value="${item.create_time}"  type="both" pattern="yyyy-MM-dd HH:mm:ss"/></td>


					</tr>
				</c:forEach>
			</table>
		</div>
		
		<vp:pages cpage="${model.cpage}" totalCount="${model.totalCount}"
			pageSize="${model.pageSize}" />
	</div>
 
 </form>  
 </div>
<div id="edit" style="display:none;width: 100%;height: 100%;overflow:hidden;position:absolute;left:0;top:0;right:0;bottom:0;">
        <iframe id="editFrame" width="100%" height="100%"  frameborder="0" border="0" scrolling="auto"></iframe>
 </div>
  <script type="text/javascript">
	function seach(){
		$("#cpage").val(1);
		oksubmit();
	}
	function oksubmit() {
	    $("#btnOk").attr("disabled", "disabled");	  
	    var objform = document.getElementById('seachform');
	    objform.submit();
	}	
	function confirm(id,type){
		if(type==0){
			layer.confirm('确认要停用此用户吗', {
				  title :'确认停用',
				  btn: ['确认','取消'] //按钮
				}, function(){
					sendOpTo(id,type);
				}, function(){
				  
				});	
		}else{
			sendOpTo(id,type);
		}

	}
	function sendOpTo(id,type){
		layer.load(1, {shade: [0.5,'#fff']});
		var postData="userId=" + id + "&opType=" + type;
		 $.ajax({
	            type: "POST",
	            url: "audit",
	            data: postData,
	            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	            async: true, // 同步  true 异步。默认是异步
	            dataType: 'json',
	            error: function(resultdata) {
	            	layer.closeAll();
	            },
	            success: function(resultdata) {
	            	layer.closeAll();
	                if(resultdata.returnCode=="0000"){               	
	                	layer.alert('操作成功',{icon: 1}, function(){
	                		layer.closeAll();
	                	 	 oksubmit();
	                	});
	                }else{
	                	layer.alert(resultdata.returnMessage);
	                }
	            }
	        });
	}
	
    function editReturn() {
       layer.closeAll();
       oksubmit();
    }
    function closeAll() {
        layer.closeAll();
     }
    function edit(id){
		var domainUrl="edit?userId=" + id;
		layer.open({
			  type: 2,
			  title: '门店用户',
			   area: ['600px', '430px'],
			   content: domainUrl //iframe的url
	      }); 
		// $('#wrap').hide();
	    // $('#editFrame').attr("src", domainUrl);
	    // $('#edit').show(); 
	}
	function editReturn() {
		  layer.closeAll();
		  $('#seach').show();
	      $('#editFrame').attr("src", "");
	      $('#edit').hide();
	      oksubmit();
		}

	</script>
<%@include file="../common/masterbottom.jsp"%>
